<?php

namespace app\common\model\presalesCustomer;

use cores\BaseModel;
use think\model\relation\BelongsTo;

class Log extends BaseModel
{
    // 定义表名
    protected $name = 'presales_customer_log';

    // 定义主键
    protected $pk = 'pcl_id';

    public function getNextTimeAttr($value, $data)
    {
        return $value ? date("Y-m-d H:i:s", $value) : '';
    }

    /**
     * 关联用户记录表
     * @return BelongsTo
     */
    public function storeUser(): BelongsTo
    {
        $module = self::getCalledModule();
        return $this->belongsTo("app\\{$module}\\model\\store\\User", 'store_user_id');
    }

    /**
     * 关联客户类型记录表
     * @return BelongsTo
     */
    public function type(): BelongsTo
    {
        $module = self::getCalledModule();
        return $this->belongsTo("app\\{$module}\\model\\presalesCustomer\\Type", 'pct_id');
    }
}
